/* See LICENSE file for copyright and license details. */

/* appearance */
static const unsigned int borderpx = 1;        /* border pixel of windows */
static const unsigned int snap     = 32;       /* snap pixel */
static const int showbar           = 1;        /* 0 means no bar */
static const int topbar            = 1;        /* 0 means bottom bar */
static const int newclientlast     = 1;        /* 1 means last client */
static const unsigned int systraypinning = 0;  /* 0 means sloppy systray follows selected monitor, >0 means pin systray to monitor X */
static const unsigned int systrayspacing = 2;  /* systray spacing */
static const int systraypinningfailfirst = 1;  /* 1 means if pinning fails, display systray on the first monitor, 0 means display systray on the last monitor */
static const int showsystray       = 1;        /* 0 means no systray */
static const char *fonts[]         = {
    "Monaco Nerd Font Mono:style=Regular:size=12",
    /* "Noto Color Emoji:pixelsize=10:antialias=true:autohint=true",  // support emoji */
};
static const char dmenufont[]  = "Monaco Nerd Font Mono:style=Regular:size=12";
static const char col_gray1[]  = "#222222";
static const char col_gray2[]  = "#444444";
static const char col_gray3[]  = "#bbbbbb";
static const char col_gray4[]  = "#eeeeee";
static const char col_cyan[]   = "#005577";
static const char col_blue[]   = "#81A1C1";  // focused window border
static const char col1[]       = "#ffffff";
static const char col2[]       = "#ffffff";
static const char col3[]       = "#ffffff";
static const char col4[]       = "#ffffff";
static const char col5[]       = "#ffffff";
static const char col6[]       = "#ffffff";
static const char *colors[][3] = {
    /*               fg         bg          border   */
    [SchemeNorm] = { col_gray3, col_gray1,  col_gray2 },
    [SchemeNorm] = { col_gray3, col_gray1,  col_gray2 },
    [SchemeCol1] = { col1,      col_gray1,  col_gray2 },
    [SchemeCol2] = { col2,      col_gray1,  col_gray2 },
    [SchemeCol3] = { col3,      col_gray1,  col_gray2 },
    [SchemeCol4] = { col4,      col_gray1,  col_gray2 },
    [SchemeCol5] = { col5,      col_gray1,  col_gray2 },
    [SchemeCol6] = { col6,      col_gray1,  col_gray2 },
    [SchemeSel]  = { col_gray4, col_cyan,   col_blue  },
    [SchemeHid]  = { col_cyan,  col_gray1,  col_cyan  },
};

/* tagging  */
static const char *tags[] = { "😀₁", "💻₂", "🌀₃", "📁₄", "🎵₅", "🎃₆", "🌈₇", "🐯₈", "🐳₉" };

static const Rule rules[] = {
    /* xprop(1):
     *  WM_CLASS(STRING) = instance, class
     *  WM_NAME(STRING) = title
     *  cmd: xprop WM_CLASS or xprop WM_NAME
     */
    /* class            instance    title           tags mask   isfloating  monitor */
    { "Gimp",           NULL,       NULL,           0,          1,          -1 },
    { "Alacritty",      NULL,       NULL,           0,          0,          -1 },
    { "Alacritty",      NULL,       "Scratchpad",   0,          1,          -1 },
    { "st-256color",    NULL,       NULL,           0,          0,          -1 },
    { "Gnome-terminal", NULL,       NULL,           0,          0,          -1 },
    { "Code",           NULL,       NULL,           1 << 1,     0,          -1 },
    { "Firefox",        NULL,       NULL,           1 << 2,     0,          -1 },
    { "Google-chrome",  NULL,       NULL,           1 << 2,     0,          -1 },
    { "File-roller",    NULL,       NULL,           1 << 2,     1,          -1 },
    { "Nautilus",       NULL,       NULL,           1 << 3,     1,          -1 },
    { "Eog",            NULL,       NULL,           1 << 3,     1,          -1 },
    { "Gitk",           NULL,       NULL,           1 << 5,     0,          -1 },
};

/* layout(s) */
static const float mfact     = 0.50; /* factor of master area size [0.05..0.95] */
static const int nmaster     = 1;    /* number of clients in master area */
static const int resizehints = 1;    /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
static const unsigned int ulinepad     = 5; /* horizontal padding between the underline and tag */
static const unsigned int ulinestroke  = 2; /* thickness / height of the underline */
static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */
static const int ulineall = 0;	/* 1 to show underline on all tags, 0 for just the active ones */

/* Note.
 * 1. gnome-terminal show gaps.
 */
static const Layout layouts[] = {
    /* symbol     arrange function */
    { "[]=",      tile },    /* first entry is default */
    { "><>",      NULL },    /* no layout function means floating behavior */
    { "[M]",      monocle },
    { "HHH",      grid },
    { "[@]",      spiral },
    { "[\\]",     dwindle },
};

/* overview */
static const Layout overviewlayout  = { "[V]", overview };

/* key definitions */
/* Mod1Mask[Alt] Mod4Mask[Win] */
#define MODKEY  Mod4Mask
#define SHIFT   ShiftMask
#define CTRL    ControlMask
#define ALT     Mod1Mask
#define TAGKEYS(KEY,TAG) \
    { MODKEY,               KEY,        view,               {.ui = 1 << TAG} }, \
    { MODKEY|CTRL,          KEY,        toggleview,         {.ui = 1 << TAG} }, \
    { MODKEY|SHIFT,         KEY,        tag,                {.ui = 1 << TAG} }, \
    { MODKEY|CTRL|SHIFT,    KEY,        toggletag,          {.ui = 1 << TAG} },

/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *roficmd[]  = { "rofi", "-show", "combi", NULL };
static const char *termcmd[]  = { "alacritty", NULL };  // st alacritty gnome-terminal
static const char scratchpadname[] = "Scratchpad";
static const char *scratchpadcmd[] = { "alacritty", "-t", scratchpadname, NULL };

static const Key keys[] = {
    /* modifier             key         function            argument */
    { MODKEY,               XK_r,       spawn,              {.v = roficmd } },
    { MODKEY,               XK_Return,  spawn,              {.v = termcmd } },
    { MODKEY,               XK_grave,   togglescratch,      {.v = scratchpadcmd } },
    { MODKEY,               XK_b,       togglebar,          {0} },
    { MODKEY,               XK_h,       focusdir,           {.i = 0 } },
    { MODKEY,               XK_j,       focusdir,           {.i = 3 } },
    { MODKEY,               XK_k,       focusdir,           {.i = 2 } },
    { MODKEY,               XK_l,       focusdir,           {.i = 1 } },
    { MODKEY,               XK_Left,    focusdir,           {.i = 0 } },
    { MODKEY,               XK_Down,    focusdir,           {.i = 3 } },
    { MODKEY,               XK_Up,      focusdir,           {.i = 2 } },
    { MODKEY,               XK_Right,   focusdir,           {.i = 1 } },
    { MODKEY|SHIFT,         XK_j,       movestack,          {.i = +1 } },
    { MODKEY|SHIFT,         XK_k,       movestack,          {.i = -1 } },
    { MODKEY|SHIFT,         XK_Down,    movestack,          {.i = +1 } },
    { MODKEY|SHIFT,         XK_Up,      movestack,          {.i = -1 } },
    { MODKEY|CTRL,          XK_Left,    movewin,            {.ui = 0 } },
    { MODKEY|CTRL,          XK_Down,    movewin,            {.ui = 1 } },
    { MODKEY|CTRL,          XK_Up,      movewin,            {.ui = 2 } },
    { MODKEY|CTRL,          XK_Right,   movewin,            {.ui = 3 } },
    { CTRL,                 XK_Tab,     focusstack,         {.i = +1 } },
    { CTRL|SHIFT,           XK_Tab,     focusstack,         {.i = -1 } },
    { ALT,                  XK_Tab,     toggleoverview,     {0} },
    { MODKEY,               XK_i,       incnmaster,         {.i = +1 } },
    { MODKEY,               XK_d,       incnmaster,         {.i = -1 } },
    { MODKEY|ALT,           XK_a,       setmfact,           {.f = -0.05 } },
    { MODKEY|ALT,           XK_m,       setmfact,           {.f = +0.05 } },
    { MODKEY|SHIFT,         XK_Return,  zoom,               {0} },
    { MODKEY,               XK_Tab,     view,               {0} },
    { MODKEY,               XK_q,       killclient,         {0} },
    { MODKEY|ALT,           XK_1,       setlayout,          {.v = &layouts[0] } },
    { MODKEY|ALT,           XK_2,       setlayout,          {.v = &layouts[1] } },
    { MODKEY|ALT,           XK_3,       setlayout,          {.v = &layouts[2] } },
    { MODKEY|ALT,           XK_4,       setlayout,          {.v = &layouts[3] } },
    { MODKEY|ALT,           XK_5,       setlayout,          {.v = &layouts[4] } },
    { MODKEY|ALT,           XK_6,       setlayout,          {.v = &layouts[5] } },
    { MODKEY|ALT,           XK_0,       setlayout,          {0} },
    { MODKEY|SHIFT,         XK_space,   togglefloating,     {0} },
    { MODKEY|ALT,           XK_j,       rotatestack,        {.i = +1 } },
    { MODKEY|ALT,           XK_k,       rotatestack,        {.i = -1 } },
    { MODKEY|SHIFT,         XK_f,       actualfullscreen,   {0} },
    { MODKEY,               XK_f,       fullscreen,         {0} },
    { MODKEY,               XK_0,       view,               {.ui = ~0 } },
    { MODKEY|SHIFT,         XK_0,       tag,                {.ui = ~0 } },
    { MODKEY,               XK_comma,   focusmon,           {.i = -1 } },
    { MODKEY,               XK_period,  focusmon,           {.i = +1 } },
    { MODKEY|SHIFT,         XK_comma,   tagmon,             {.i = -1 } },
    { MODKEY|SHIFT,         XK_period,  tagmon,             {.i = +1 } },
    { MODKEY|ALT,           XK_s,       show,               {0} },
    { MODKEY|ALT,           XK_h,       hide,               {0} },
    { MODKEY|SHIFT,         XK_q,       quit,               {0} },
    { MODKEY|SHIFT,         XK_r,       quit,               {1} },
    TAGKEYS(                XK_1,       0)
    TAGKEYS(                XK_2,       1)
    TAGKEYS(                XK_3,       2)
    TAGKEYS(                XK_4,       3)
    TAGKEYS(                XK_5,       4)
    TAGKEYS(                XK_6,       5)
    TAGKEYS(                XK_7,       6)
    TAGKEYS(                XK_8,       7)
    TAGKEYS(                XK_9,       8)
};

/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkWinTitle, ClkStatusText, ClkClientWin, or ClkRootWin */
/* Button1 [The left mouse button]
 * Button2 [The middle mouse button]
 * Button3 [The right mouse button]
 * Button4 [The mouse up button]
 * Button5 [The mouse down button]
 */
static const Button buttons[] = {
    /* click            eventmask   button      function        argument */
    { ClkTagBar,        0,          Button1,    view,           {0} },
    { ClkTagBar,        0,          Button3,    toggleview,     {0} },
    { ClkTagBar,        MODKEY,     Button1,    tag,            {0} },
    { ClkTagBar,        MODKEY,     Button3,    toggletag,      {0} },
    { ClkTagBar,        0,          Button4,    viewtoleft,     {0} },
    { ClkTagBar,        0,          Button5,    viewtoright,    {0} },
    { ClkWinTitle,      0,          Button1,    togglewin,      {0} },
    { ClkWinTitle,      0,          Button2,    zoom,           {0} },
    { ClkWinTitle,      0,          Button3,    togglehidden,   {0} },
    { ClkLtSymbol,      0,          Button1,    cyclelayout,    {.i = -1 } },
    { ClkLtSymbol,      0,          Button3,    cyclelayout,    {.i = +1 } },
    { ClkStatusText,    0,          Button1,    sigdwmblocks,   {.i = 1 } },
    { ClkStatusText,    0,          Button2,    sigdwmblocks,   {.i = 2 } },
    { ClkStatusText,    0,          Button3,    sigdwmblocks,   {.i = 3 } },
    { ClkStatusText,    0,          Button4,    sigdwmblocks,   {.i = 4 } },
    { ClkStatusText,    0,          Button5,    sigdwmblocks,   {.i = 5 } },
    { ClkClientWin,     MODKEY,     Button1,    movemouse,      {0} },
    { ClkClientWin,     MODKEY,     Button2,    togglefloating, {0} },
    { ClkClientWin,     MODKEY,     Button3,    resizemouse,    {0} },
};
